#ifndef SRMEDIAPLAYER_H
#define SRMEDIAPLAYER_H

#include "mediaplaylist.h"
#include "controlwidget.h"

#include <QMainWindow>
#include <QVideoWidget>
#include <QMediaPlayer>

QT_BEGIN_NAMESPACE
namespace Ui {
class SRMediaPlayer;
}
QT_END_NAMESPACE

class SRMediaPlayer : public QMainWindow
{
    Q_OBJECT

public:
    SRMediaPlayer(QWidget *parent = nullptr);
    ~SRMediaPlayer();

public:
    // 给到控制界面使用
    void on_PlayButton_clicked();
    void on_PauseButton_clicked();
    void on_NextButton_clicked();
    void on_PreviousButton_clicked();
    void on_sliderMoved(int position);

signals:
    void progressSliderValueChanged(int position); // 定义信号
    void durationChanged(qint64 duration); // 定义信号

private slots:
    void on_BrowseButton_clicked();

private:
    void on_positionChanged(qint64 position);
    void on_durationChanged(qint64 duration);
    void updateFilenameDisplay(const QUrl &media);
    void paintEvent(QPaintEvent *e);
    void resizeEvent(QResizeEvent *event);
    void moveEvent(QMoveEvent *event);
    bool eventFilter(QObject *obj, QEvent *event);
    void setVolume(int volume);  // 音量设置

    ControlWidget *controlwidget;
    QVideoWidget *qVideoWidget;
    QMediaPlayer *qPlayer;
    MediaPlaylist *qPlaylist;
    Ui::SRMediaPlayer *ui;
};

#endif // SRMEDIAPLAYER_H
